package com.question;

import java.util.ArrayList;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

public class QuestionHM12 {
    static int a=0;
    static String data;
    public  static  void  main(String []args)
    {
        final ArrayList<String> arrayList=new ArrayList<String>();

        for(int i=0;i<25;i++)
        {
            String data=i+"";
            arrayList.add(data);
            //process(data);
        }

        for (int j=0;j<5;j++)
        {
            new Thread(new Runnable() {
                public void run() {
                    while (a<25)
                    {
                        synchronized (QuestionHM12.class)
                        {
                            data= arrayList.get(a);
                            a++;
                        }
                        process(data);
                    }

                }
            }).start();
        }





    }
    static void  process(String data)
    {
        try {
            System.out.println(Thread.currentThread().getName()+"处理数据——"+ data+"——在时间"+System.currentTimeMillis());
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

